package com.fzz.learning_forum.dao;


import com.fzz.learning_forum.domain.Admin;
import com.fzz.learning_forum.domain.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface AdminMapping {

    //管理员登录
    @Select("select * from tb_admin where adminName=#{adminName} and password=#{password}")
    public Admin adminLogin(@Param("adminName")String adminName,@Param("password")String password);

    //查询所有的用户
    @Select("select * from tb_user")
    public List<User> selectUserWithPage();

    //根据id禁用用户
    @Update("update tb_user set valid='0' where id=#{id}")
    public Integer deleteUserById(@Param("id") Integer id);

    //根据id授权用户
    @Update("update tb_user set valid='1' where id=#{id}")
    public Integer empowerUserById(@Param("id") Integer id);

    //根据id授权动态
    @Update("update tb_article set valid='1' where id=#{id}")
    public Integer empowerArticleById(@Param("id") Integer id);

    //根据id禁用
    @Update("update tb_article set valid='0' where id=#{id}")
    public Integer deleteArticleById(@Param("id") Integer id);

}
